package com.haixin;

import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @ProjectName: haixin-tianqipaqu
 * @Package: com.haixin.service
 * @ClassName: Test
 * @Author: lfh
 * @Description:
 * @Date: 2020/5/11 15:13
 * @Version: 1.0
 */
public class Test {

    public static void main(String[] args) throws IOException {

//        String a="http://image.nmc.cn/product/2020/05/11/WESA/SEVP_NMC_WESA_SFER_EGH_ACWP_L00_P9_20200511030000000.png";
//        File file = new File("D:/pic/a.test");
//        if(!file.exists()){
//            System.out.println("创建文件");
//            file.createNewFile();
//        }
        URL url = new URL("http://www.nmc.cn/publish/satellite/FY4A-infrared.htm");
        DataInputStream dataInputStream = null;
            dataInputStream = new DataInputStream(url.openStream());
            InputStreamReader inputStreamReader = new InputStreamReader(dataInputStream);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            String s = bufferedReader.readLine();
            int a=1;
            while((s=bufferedReader.readLine())!=null){
                if(a==7){
                    System.out.println(s);
                    break;
                }
                a++;
            }
        String content = " data-img=http://image.nmc.cn/product/2020/05/12/WXBL/medium/SEVP_NSMC_WXBL_FY4A_EC012_ACHN_LNO_PY_20200512072300000.JPG?v=1589269382057" ;

        List<String> strs = new ArrayList<String>();
        Pattern p = Pattern.compile("http:\\/\\/.*\\.JPG");
        Matcher m = p.matcher(s);
        while(m.find()) {
            strs.add(m.group());

        }
        for (String str : strs) {
            System.out.println(str);
        }
//        Pattern.matches(pattern, content);





//        String file1 = url.getFile();
//        Date now = new Date();
//        Calendar cal1 = Calendar.getInstance();
////        cal1.setTime(now);
//        // 将时分秒,毫秒域清零
//        cal.set(Calendar.HOUR_OF_DAY, 0);//控制时
//        cal.set(Calendar.MINUTE, 0);//控制分
//        cal.set(Calendar.SECOND, 0);//控制秒
//
//        System.out.printf("%1$tF %1$tT\n", cal1.getTime());

//            Date date = new Date(1589112107695l);
//            System.out.println(date.getMonth());
//        DateFormat df1=DateFormat.getDateInstance();
//        DateFormat df3=DateFormat.getDateTimeInstance();
//        System.out.println(df3.format(date));
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

//        Calendar instance = Calendar.getInstance();
    }
}
